using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SingletonpatternMonoBase<T> : MonoBehaviour where T : MonoBehaviour
{

    protected SingletonpatternMonoBase() { }

    private static T instance;

    public static T Instance
    {
        get
        {
            if (instance == null)
            {
                instance=FindObjectOfType<T>();
                if(instance == null )
                {
                    GameObject gameObject = new GameObject(typeof(T).Name);
                    gameObject.AddComponent<T>();

                }
                
            }
            return instance;
        }
    }
}